package com.controller;

import com.model.Orders;
import com.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/elm/OrdersController")
public class OrdersController {
    @Autowired
    OrdersService service;
    @PostMapping("/listOrdersByUserId")
    public Object listOrdersByUserId(String userId)throws Exception{
        List<Orders> orders = service.listOrdersByUserId(userId);
        return orders;
    }
    @PostMapping("/getOrdersById")
    public Object getOrdersById(int orderId)throws Exception{
        Orders orders = service.getOrdersById(orderId);
        return orders;
    }
    @PostMapping("/createOrders")
    public Object createOrders(String userId, int businessId, int daId)throws Exception{
        int orders = service.createOrders(userId, businessId, daId);
        return orders;
    }

}
